<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 = new Promise ((resolve,reject)=>{
            console.log('开始请求数据');
            try{
                //throw new Error
                //使用定时器模拟ajax请求
                setTimeout(()=>{
                    console.log('数据请求成功');
                    resolve('ok')
                },2000)
            } catch(e){
                //catch接收的是错误对象
                console.log(e);
                //e上有个message属性,就是当前错误的信息
                console.log(e.message);
                reject(e.message)
            }
        })
        console.log('p1',p1);
    </script>
</body>
</html>